class Solution {
public:
    int sumOddLengthSubarrays(vector<int>& arr)
    {
        vector<int> presum = {0};
        for(int e: arr) presum.push_back(presum.back() + e);
        int res = 0;
        for(int i = 0; i < arr.size(); i ++)
            for(int sz = 1; i + sz - 1 < arr.size(); sz += 2)
                res += presum[i + sz] - presum[i];
        return res;
    }
};